package com.powernode.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.powernode.EsDomin.ProdEs;
import com.powernode.service.SearchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@RequestMapping
@Api(tags = "搜索商品接口")
@RestController
public class SearchController {

    @Autowired
    private SearchService searchService;


    @GetMapping("/search/searchProdPage")
    @ApiOperation("小程序搜索接口")
    public ResponseEntity<Page<ProdEs>> searchProdPage( @RequestParam(defaultValue = "1")Integer current, Integer size, String prodName, Integer sort) {
        Page<ProdEs> page = searchService.ResponseEntity(current, size, prodName, sort);
        return ResponseEntity.ok(page);
    }


    @GetMapping("/prod/prodListByTagId")
    @ApiOperation("首页标签商品")
    public ResponseEntity<Page<ProdEs>> prodListByTagId(@RequestParam(defaultValue = "1") Integer current, Integer size, Long tagId) {
        Page<ProdEs> page = searchService.prodListByTagId(current, size, tagId);
        return ResponseEntity.ok(page);
    }

    @GetMapping("/prod/pageProd")
    @ApiOperation("小程序分类下商品查询")
    public ResponseEntity<Page<ProdEs>> pageProd(Long cateGoryId) {
        Page<ProdEs> page = searchService.pageProd(cateGoryId);
        return ResponseEntity.ok(page);
    }
}
